package com.yituo.mjworld.mvc.entity.web;

import com.yituo.mjworld.core.annotation.Rules;
import com.yituo.mjworld.core.web.core.BaseForm;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "web_shop_cut", schema = "web_mojianworld_server", catalog = "")
public class WebShopCut extends BaseForm {
  public int id;
  public String userId;
  @Rules(fieldName = "产品ID", min = "0")
  public int productId;
  @Rules(fieldName = "购买数量", min = "0")
  public int num;
  @Rules(fieldName = "总价")
  public BigDecimal totalPrice;
  @Rules(fieldName = "最终定价")
  public BigDecimal finalPrice;
  @Rules(fieldName = "定价说明", required = false)
  public String template;
  public Date createDate;

  @Id
  @Column(name = "id", nullable = false)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  @Basic
  @Column(name = "userId", nullable = false, length = 36)
  public String getUserId() {
    return userId;
  }

  public void setUserId(String userId) {
    this.userId = userId;
  }

  @Basic
  @Column(name = "productId", nullable = false)
  public int getProductId() {
    return productId;
  }

  public void setProductId(int productId) {
    this.productId = productId;
  }

  @Basic
  @Column(name = "num", nullable = false)
  public int getNum() {
    return num;
  }

  public void setNum(int num) {
    this.num = num;
  }

  @Basic
  @Column(name = "totalPrice", nullable = false, precision = 2)
  public BigDecimal getTotalPrice() {
    return totalPrice;
  }

  public void setTotalPrice(BigDecimal totalPrice) {
    this.totalPrice = totalPrice;
  }

  @Basic
  @Column(name = "finalPrice", nullable = false, precision = 2)
  public BigDecimal getFinalPrice() {
    return finalPrice;
  }

  public void setFinalPrice(BigDecimal finalPrice) {
    this.finalPrice = finalPrice;
  }

  @Basic
  @Column(name = "template", nullable = false, length = 400)
  public String getTemplate() {
    return template;
  }

  public void setTemplate(String template) {
    this.template = template;
  }

  @Basic
  @Column(name = "createDate", nullable = false)
  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }


  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + (userId != null ? userId.hashCode() : 0);
    result = 31 * result + productId;
    result = 31 * result + num;
    result = 31 * result + (totalPrice != null ? totalPrice.hashCode() : 0);
    result = 31 * result + (finalPrice != null ? finalPrice.hashCode() : 0);
    result = 31 * result + (template != null ? template.hashCode() : 0);
    result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
    return result;
  }

  @Override
  public boolean validate() {
    return defaultValidate();
  }
}
